package com.kaoshi.myweb.snippet.mq.rabbitmq.spring.integration;

import com.alibaba.fastjson.JSONObject;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TopicMessageConsumerService implements MessageListener{
	
	@Autowired
	private AmqpTemplate topicTemplate;

	public void onMessage(Message message) {
		User user = JSONObject.parseObject(new String(message.getBody()), User.class);
		System.out.println("topic接收到消息：" + user.getName());
	}
}
